<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<style>
    .fontred {
        color: red;
    }

    .fontsize {
        font-size: 100px
    }
</style>

<body>
    <div id="app">
        <div :class="classObject"> red</div>
        <button @click="changeVal">按钮</button>
    </div>

    <script>
        //创建Vue实例,得到 ViewModel
        var vm = new Vue({
            el: '#app',
            data: {
                classObject: {
                    fontred: true,
                    fontsize: true
                }
            },
            methods: {
                changeVal() {
                    this.classObject.fontred = !this.classObject.fontred
                }
            }
        });
    </script>
</body>

</html>